function OtherPrecon() {
};

OtherPrecon.instance = function(callbackFunc) {
  var popupBox = new PopupBox(), _self = this;
  
  var model = Model.instance('{{$smarty.const.MODEL_NAME_PRECON|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_PRECON|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_ORDER|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(model, 0, 'not activate (No Wedding Day)');
  var state2 = State.instance(model, 1, 'arrange Pre-con');
  var state3 = State.instance(model, 2, 'Pre-con arranged');
  var transition1 = Transition.instance('arrange', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.none);
  
  var transition2 = Transition.instance('arrange', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.none);

  var transition3 = Transition.instance('arrange', state2, state3, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.none);

  transition1.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var preconUsers = [];
                                                                                    var func1 = function() { if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.preconUsers = preconUsers;
                                                                                                             if (preconUsers.length == 0 || !produce.when) {
                                                                                                               window.alert('选择一个工作人员和一个时间');
                                                                                                               return;
                                                                                                             }
                                                                                                             var str = '';
                                                                                                             for (var i = 0, il = preconUsers.length; i < il; i++) {
                                                                                                               var u = preconUsers[i];
                                                                                                               if (u.trackId == '') {
                                                                                                                 continue;
                                                                                                               }
                                                                                                               str += u.account;
                                                                                                               if (i < preconUsers.length - 1) {
                                                                                                                 str += ', ';
                                                                                                               }
                                                                                                             }
                                                                                                             if (produce.when.hours == 0 && produce.when.minutes == 0 ) {
                                                                                                               var r = window.confirm('Hours & Minutes is  (00:00), CONTINUE?');
                                                                                                               if (r) {
                                                                                                                 options.extra = SimpleDate.format(produce.when, true) + ' ' + str;
                                                                                                                 DlmanageUtils.operate(transition1, pos, callbackFunc, produce, user, date, options);
                                                                                                                 popupBox._close();
                                                                                                               }
                                                                                                             } else {
                                                                                                               options.extra = SimpleDate.format(produce.when, true) + ' ' + str;
                                                                                                               DlmanageUtils.operate(transition1, pos, callbackFunc, produce, user, date, options);
                                                                                                               popupBox._close();
                                                                                                             }
                                                                                                           };
                                                                                    var func2 = function() { popupBox._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                    new DialogAssignee(div, produce, { php: 'customphp/mysqlread.php', condition: 'd.pEnabled = 1 OR d.vEnabled = 1', date: true, preconUsers: preconUsers });
                                                                                  };
                                                                                  
  transition2.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    var div = document.createElement('div');
                                                                                    var preconUsers = [];
                                                                                    var func1 = function() { if (!options) {
                                                                                                               options = {};
                                                                                                             }
                                                                                                             options.preconUsers = preconUsers;
                                                                                                             if (preconUsers.length == 0 || !produce.when) {
                                                                                                               window.alert('选择一个工作人员和一个时间');
                                                                                                               return;
                                                                                                             }
                                                                                                             var str = '';
                                                                                                             for (var i = 0, il = preconUsers.length; i < il; i++) {
                                                                                                               var u = preconUsers[i];
                                                                                                               if (u.trackId == '') {
                                                                                                                 continue;
                                                                                                               }
                                                                                                               str += u.account;
                                                                                                               if (i < preconUsers.length - 1) {
                                                                                                                 str += ', ';
                                                                                                               }
                                                                                                             }
                                                                                                             if (produce.when.hours == 0 && produce.when.minutes == 0 ) {
                                                                                                               var r = window.confirm('Hours & Minutes is  (00:00), CONTINUE?');
                                                                                                               if (r) {
                                                                                                                 options.extra = SimpleDate.format(produce.when, true) + ' ' + str;
                                                                                                                 DlmanageUtils.operate(transition2, pos, callbackFunc, produce, user, date, options);
                                                                                                                 popupBox._close();
                                                                                                               }
                                                                                                             } else {
                                                                                                               options.extra = SimpleDate.format(produce.when, true) + ' ' + str;
                                                                                                               DlmanageUtils.operate(transition2, pos, callbackFunc, produce, user, date, options);
                                                                                                               popupBox._close();
                                                                                                             }
                                                                                                           };
                                                                                    var func2 = function() { popupBox._close();
                                                                                                             callbackFunc();
                                                                                                           };
                                                                                    MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                    new DialogAssignee(div, produce, { php: 'customphp/mysqlread.php', condition: 'd.pEnabled = 1 OR d.vEnabled = 1', date: true, preconUsers: preconUsers });
                                                                                  };
  transition3.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  var div = document.createElement('div');
                                                                                  var preconUsers = [];
                                                                                  var func1 = function() { if (!options) {
                                                                                                             options = {};
                                                                                                           }
                                                                                                           options.preconUsers = preconUsers;
                                                                                                           if (preconUsers.length == 0 || !produce.when) {
                                                                                                             window.alert('选择一个工作人员和一个时间');
                                                                                                             return;
                                                                                                           }
                                                                                                           var str = '';
                                                                                                           for (var i = 0, il = preconUsers.length; i < il; i++) {
                                                                                                             var u = preconUsers[i];
                                                                                                             if (u.trackId == '') {
                                                                                                               continue;
                                                                                                             }
                                                                                                             str += u.account;
                                                                                                             if (i < preconUsers.length - 1) {
                                                                                                               str += ', ';
                                                                                                             }
                                                                                                           }
                                                                                                           if (produce.when.hours == 0 && produce.when.minutes == 0 ) {
                                                                                                             var r = window.confirm('Hours & Minutes is  (00:00), CONTINUE?');
                                                                                                             if (r) {
                                                                                                               options.extra = SimpleDate.format(produce.when, true) + ' ' + str;
                                                                                                               DlmanageUtils.operate(transition3, pos, callbackFunc, produce, user, date, options);
                                                                                                               popupBox._close();
                                                                                                             }
                                                                                                           } else {
                                                                                                             options.extra = SimpleDate.format(produce.when, true) + ' ' + str;
                                                                                                             DlmanageUtils.operate(transition3, pos, callbackFunc, produce, user, date, options);
                                                                                                             popupBox._close();
                                                                                                           }
                                                                                                         };
                                                                                  var func2 = function() { popupBox._close();
                                                                                                           callbackFunc();
                                                                                                         };
                                                                                  MiscUtils.dialog(popupBox, pos, div, func1, func2);
                                                                                  new DialogAssignee(div, produce, { php: 'customphp/mysqlread.php', condition: 'd.pEnabled = 1 OR d.vEnabled = 1', date: true, preconUsers: preconUsers });
                                                                                };
  model.states = [ state1, state2, state3 ];
  model.transitions = [ transition1, transition2, transition3 ];
  return model;
};